package com.mcflies.aotoPartsManager.action;

import javax.servlet.ServletContext;

import org.apache.log4j.Logger;
import org.apache.struts2.StrutsStatics;

import com.mcflies.aotoPartsManager.service.AutoPartsBaseService;
import com.mcflies.aotoPartsManager.util.AutoPartsConstantKey;
import com.mcflies.aotoPartsManager.util.AutoPartsServiceFactory;
import com.mcflies.commons.commons.CommonsConstantKey;
import com.opensymphony.xwork2.ActionContext;

import net.sf.json.JSONArray;

/**
 * 
 * AutoPartsBaseAction.java
 * 
 * @describe：汽车配件管理系统：：基础响应类
 * @Copyright(c) 2012-2024 Study,mcfly
 * @author mcfly_jun
 */
public class AutoPartsBaseAction {
	ServletContext servletContext = (ServletContext) ActionContext.getContext().get(StrutsStatics.SERVLET_CONTEXT);
	private Logger log = Logger.getLogger(AutoPartsBaseAction.class);
	private JSONArray retJSONArr;

	/**
	 * 响应左侧导航菜单树请求
	 * 
	 * @return
	 */
	public String loadLeftMenuTree() {
		try {
			retJSONArr = (JSONArray) servletContext
					.getAttribute(CommonsConstantKey.BaseDataLoadListenerConstant.BaseDataLoadListenerLEFTMENUTREEJSONARRAY);
			if (null == retJSONArr) {
				AutoPartsBaseService baseService = AutoPartsServiceFactory.initAutoPartsBaseService();
				retJSONArr = baseService.loadLeftMenuTreeJSON();
			}
		} catch (Exception e) {
			log.info("在[" + AutoPartsBaseAction.class.getName() + "]执行(loadLeftMenuTree)抛出::" + e.getMessage() + "异常");
		}
		return AutoPartsConstantKey.RETURN_JSON_ARRAY_TYPE;
	}

	public JSONArray getRetJSONArr() {
		return retJSONArr;
	}

	public void setRetJSONArr(JSONArray retJSONArr) {
		this.retJSONArr = retJSONArr;
	}

}
